package org.hbgl.geoentity.core.util;

import java.time.LocalTime;

/**
 * 代码功能：
 * 开发日期：2022/10/9
 * 作者：蒋海仑
 * 联系方式：
 * 版本更迭说明：
 * 版权信息：河北广联信息技术有限公司
 * @author Administrator
 */
public class GreetingMaker {

    private static final LocalTime MORNING = LocalTime.of(0, 0, 0);
    private static final LocalTime NOON = LocalTime.of(11, 0, 0);
    private static final LocalTime AFTER_NOON = LocalTime.of(13, 0, 0);
    private static final LocalTime NIGHT = LocalTime.of(16, 0, 0);

    public static String printTimeOfDay() { // or return String in your case
        if (between(MORNING, NOON)) {
            return "早上好";
        } else if (between(NOON, AFTER_NOON)) {
            return "中午好";
        } else if (between(AFTER_NOON, NIGHT)) {
            return "下午好";
        } else {
            return "晚上好";
        }
    }

    public static boolean between(LocalTime start, LocalTime end) {
        LocalTime now = LocalTime.now();
        return (!now.isBefore(start)) && now.isBefore(end);
    }

    public static void main(String[] args) {
        String s = printTimeOfDay();
        System.out.println(s);
    }

}
